<?php
require_once '../../controllers/seguridad.php';
require_once '../layout/head.php';
include_once '../../class/classUtils.php';
include_once '../../class/classFormulario.php';

$utils = new Utils();
$formulario = new Formulario();
$lstUsuarios = $Usuarios->listarUsuarios();
?>	

<script type="text/javascript" src="../layout/js/funciones.js"></script>

<div id="generalcontent2">
    <div class="title">Administraci&oacute;n de Empresas</div>
    <div id="contenidos">

        <?php
        if (isset($_REQUEST['e']) && $_REQUEST['e'] != "") {

            $utils->mensaje($_REQUEST['e'], $_REQUEST['t']);
        }
        ?>			


        <br><br><a href="grabar_emp.php?id=-1&r=<?php echo $_REQUEST['r']; ?> "><img src='../../views/layout/img/icons/Plus.gif' alt='Agregar' border='0' align='absmiddle'/> Agregar Empresa</a>	
        <hr></hr>
        <div align ="left">
            <br>
            <table width="100%" class="sortable-onload-0 no-arrow rowstyle-alt colstyle-alt paginate-10 max-pages-10 rowstylehover-rowHover colstylehover-rowHover cellhover-currentCell">
                <caption>Listado de Empresas</caption>
                <th>Rut</th>
                <th>Usuario</th>
                <th class="sortable-text">Nombre</th>
                <th class="sortable-text">Estado</th>

                <th>Editar</th>
                <th>Activar/Desactivar</th>
                </tr>

                <?php
                foreach ($lstUsuarios as $usr) {
                    echo "<tr>";
                    echo "<td>" . $usr->USU_RUT . " - " . $usr->USU_DV . "</td>";
                    echo "<td>$usr->USU_USUARIO</td>";
                    echo "<td>" . $usr->USU_NOMBRES . " " . $usr->USU_AP_PATERNO . " " . $usr->USU_AP_MATERNO . "</td>";

                    if ($usr->USU_ESTADO == 1) {
                        echo "<td > <span style='color: Green;'>Activo</span></td>";
                    } else {
                        echo "<td > <span style='color: red'>Inactivo</span></td>";
                    }

                    echo "<td><a href='grabar.php?&id=" . $usr->USU_ID . "' class='editar'><img src='../../views/layout/img/icons/Pen.gif' alt='Editar' border='0' align='absmiddle'/> Editar</a></td>";

                    if ($usr->USU_ESTADO == 1) {
                        echo "<td><a href='eliminar.php?id=" . $usr->USU_ID . "&ext=-1' class='eliminar'><img src='../../views/layout/img/icons/Close.gif' alt='Desactivar' border='0' align='absmiddle'/> Desactivar</a></td>";
                    } else {
                        echo "<td><a href='eliminar.php?id=" . $usr->USU_ID . "&ext=1' class='eliminar'><img src='../../views/layout/img/icons/Ok2.gif' alt='Desactivar' border='0' align='absmiddle'/>Activar</a></td>";
                    }
                    echo "</tr>";
                }
                ?>						
            </table>
        </div>
        <?php
        require_once '../layout/pie.php';
        ?>
			